// theory the registry is known to contain this version. If, however, we
// come back with no summaries, then our registry may need to be
// updated, so we fall back to performing a lazy update.
- if dep.get_source_id().get_precise().is_some() &&
- try!(self.summaries(dep.get_name())).len() == 0 {
- try!(self.do_update());
+ if dep.get_source_id().get_precise().is_some() {
+ let mut summaries = try!(self.summaries(dep.get_name())).iter().map(|s| {
+ s.0.clone()
+ }).collect::<Vec<_>>();
+ if try!(summaries.query(dep)).len() == 0 {
+ try!(self.do_update());
+ }
}
let summaries = try!(self.summaries(dep.get_name()));
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0).with_stdout(""));
})
+
+test!(update_publish_then_update {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+ name = "foo"
+ version = "0.5.0"
+ authors = []
+
+ [dependencies]
+ a = "0.1.0"
+ "#)
+ .file("src/main.rs", "fn main() {}");
+ p.build();
+
+ r::mock_pkg("a", "0.1.0", &[]);
+
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
+ execs().with_status(0));
+
+
+ r::mock_pkg("a", "0.1.1", &[]);
+
+ let lock = p.root().join("Cargo.lock");
+ let s = File::open(&lock).unwrap().read_to_string().unwrap();
+ File::create(&lock).unwrap().write_str(s.replace("0.1.0", "0.1.1").as_slice())
+ .unwrap();
+ println!("second");
+
+ fs::rmdir_recursive(&p.root().join("target")).unwrap();
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
+ execs().with_status(0).with_stdout(format!("\
+{updating} [..]
+{downloading} a v0.1.1 (registry file://[..])
+{compiling} a v0.1.1 (registry [..])
+{compiling} foo v0.5.0 ({dir})
+", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
+ dir = p.url()).as_slice()));
+
+})